#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int INF = 1 << 30;
const ldb pi = fabsl(atan2(0.0, -1.0));
using namespace std;

int n, m;
int p[2202];
int edges;
int nxt[42000], fst[33000], end[42000];

void Load()
{
	cin >> n >> m;
	memset(fst , -1, sizeof fst);
	int i;
	for (i = 0; i <= m; i++)
	{
		cin >> p[i];
		a[i] = p[i];
		b[i] = p[i + 1];
	}
	sort()
}
vector <int> res;
bool was[42000];

void addEdge(int i, int j)
{
	nxt[edges] = fst[i];
	fst[i] = edges;
	end[edges] = j;
	edges++;
}


void go(int ver, int i, int &less, int cnt)
{
	if (cnt + 1 == i && less == 0) return;
	int u;
	int mi = -1;
	for (u = fst[ver]; u != -1; u = nxt[u])
	{
		if (cnt == 1)
		cerr << "we have variant " << end[u] << "\n";
		if (was[u]) continue;
		if (less == 0 && (end[u] < p[i] || end[u] == p[i] && i == cnt)) continue;
		if (mi == -1 || end[mi] > end[u]) mi = u;
	}
	if (cnt == 1)
	cerr << ver << " " << i << " " << less << " " << end[mi] << " " << less << "\n";
//	1 2 3 2 4 1
	if (mi != -1)
	{
		was[mi] = was[mi ^ 1] = 1;
		if (end[mi] > p[i]) less = 1;
		go(end[mi], i + 1, less, cnt);
		res.push_back(end[mi]);
		i++;
		for (u = fst[ver]; u != -1; u = nxt[u])
		{
			if (was[u] == 1) continue;
			if (less == 0 && (end[u] < p[i] || end[u] == p[i] && i == cnt)) continue;
			was[u] = was[u ^ 1];
			go(end[u])
	
		}
	}
}

void Solve()
{
	int i;
	for (i = 0; i < m; i++)
	{
		addEdge(p[i], p[i + 1]);
		addEdge(p[i + 1], p[i]);
	}
	
	int l = 1;
	int r = m;
	int mid;
	int ans = -1;
	int ls;
	while (l <= r)
	{
		mid = (l + r) / 2;
		res.resize(0);
		for (i = 0; i < edges; i++) was[i] = 0;
		ls = 0;
		go(1, 1, ls, mid);
		res.push_back(1);
		if (res.size() == m + 1)
		{
			ans = mid;
			l = mid + 1;
		}
		else
		{
			r = mid - 1;
		}

	}
	if (ans == -1)
	{
		cout << "No solution";
		return;
	}
	res.resize(0);
	for (i = 0; i < edges; i++) was[i] = 0;
	ls = 0;
	go(1, 1, ls, ans);
	res.push_back(1);
	reverse(res.begin(), res.end());
	for (i = 0; i < res.size(); i++)
	{
		cout << res[i] << " ";
	}
}

#define file "d"
int main()
{
	#ifndef ONLINE_JUDGE
	freopen(file".in", "rt", stdin);
	freopen(file".out", "wt", stdout);
	#endif
	Load();
	Solve();
	return 0;
}